//#include <stdint.h>

typedef   signed          char CHAR;
typedef   signed short     int SHORT;
typedef   signed           int LONG;
//typedef   signed       __int64 int64_t;

    /* exact-width unsigned integer types */
typedef unsigned          char U8;
typedef unsigned short     int U16;
typedef unsigned           int U32;

typedef unsigned char  bool;                   	                   
enum 
{FALSE = 0, 
TRUE = 1};

#define RED_LED_VAL      (1<<9)
#define	ORG_LED_VAL			(1<<13)
#define	BLUE_LED_VAL		1
#define	GREEN_LED_VAL		2

#define	LED_FLASH_TIME	5
typedef     struct   LED_CTRL_TAG{
	union {
		U8    Byte;
		struct{
			U8    Red	    :1;
			U8    Orange	:1;
			U8    Blue 		:1;
			U8    Green   :1;
			U8    reserved  :4;
		}BIT;
	}STATUS;
	union {
		U8    Byte;
		struct{
			U8    Red	    :1;
			U8    Orange	:1;
			U8    Blue 		:1;
			U8    Green   :1;
			U8    reserved  :4;
		}BIT;
	}FLS;
	U16 LED_Flash_Time;
}LED_CTRL;

typedef union{
	U16	value;
	struct{
	bool DS1 :1;
	bool PaperEnd :1;
	bool DS3 :1;
	bool DS4 :1;
	bool PaperInsert :1;
	bool DS6 :1;
	bool FS1 :1;
	bool Seal :1;
	bool FS3 :1;
	bool FS4 :1;
	bool FS5 :1;
	bool FS6 :1;
	}BIT;
}SENSOR;

typedef union{
	U16	value;
	struct{
	bool DS1 :1;
	bool DS2 :1;
	bool DS3 :1;
	bool DS4 :1;
	bool PaperEnd :1;
	bool DS6 :1;
	bool FS1 :1;
	bool SealMotor :1;
	bool FS3 :1;
	bool FS4 :1;
	bool FS5 :1;
	bool FS6 :1;
	}BIT;
}ERROR_FLAG;

typedef struct{
	U16	time;
	bool	busy;
}MOS_DC;

typedef struct {
	bool working;
}Device_Status;

enum{
	SEAL_HOME_MOVE = 0,
	SEAL_CTRL_MOVE,
	SEAL_MOVE,
	PF_LOAD_MOVE = 0,
	PF_SEAL_MOVE,
	PF_EJECT_MOVE,
	PF_CTRL_MOVE
};

enum {
	SEAL_SLOW_SPEED = 0,
//	SEAL_NORMAL_SPEED,
//	SEAL_FAST_SPEED,
	PF_SLOW_SPEED = 0,
//	PF_NORMAL_SPEED,
//	PF_FAST_SPEED
};

enum {
	PF_MOTOR = 1,
	SEAL_MOTOR
};
typedef	struct {
	U8 * pbStart;
	U8 * pbEnd;
	U8 * pbload;
	U8 * pbsave;
	U16	dwsize;
} IOBUFFER;

typedef	struct {
	IOBUFFER iobuf_rx;
	IOBUFFER iobuf_tx;
	union{
		U8	status;
		struct{
			volatile	U8	bSerialBusy	:	1;
			U8	bSerialActive:1;
			U8	bTxBuffDataIn	:	1;
			U8	bTxBuffFull:	1;
		}BIT;
	}RingFlag;
}	RECV_BUF;

#define	RV_SIZE	256
#define	TX_SIZE	128
#define	DEFAULT_SEAL1_POS		20
#define	DEFAULT_SEAL2_POS		0
enum{
	LEDON = 1,
	LEDOFF = 0,
	ALL_LEDON = 0x0F,
	ALL_LEDOFF = 0x0,
	ALL_LED_FLASH_ON = 0x0F,
	ALL_LED_FLASH_OFF = 0,
	LED_FLASH_ON = 1,
	LED_FLASH_OFF = 0,
	LED_MASK = 0x0F
};
